import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/common/get_department_tree_entity.dart';

GetDepartmentTreeEntity $GetDepartmentTreeEntityFromJson(Map<String, dynamic> json) {
  final GetDepartmentTreeEntity getDepartmentTreeEntity = GetDepartmentTreeEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    getDepartmentTreeEntity.id = id;
  }
  final String? pid = jsonConvert.convert<String>(json['pid']);
  if (pid != null) {
    getDepartmentTreeEntity.pid = pid;
  }
  final String? departmentName = jsonConvert.convert<String>(json['departmentName']);
  if (departmentName != null) {
    getDepartmentTreeEntity.departmentName = departmentName;
  }
  final List<GetDepartmentTreeEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<GetDepartmentTreeEntity>(e) as GetDepartmentTreeEntity).toList();
  if (children != null) {
    getDepartmentTreeEntity.children = children;
  }
  final bool? isExpand = jsonConvert.convert<bool>(json['isExpand']);
  if (isExpand != null) {
    getDepartmentTreeEntity.isExpand = isExpand;
  }
  return getDepartmentTreeEntity;
}

Map<String, dynamic> $GetDepartmentTreeEntityToJson(GetDepartmentTreeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['pid'] = entity.pid;
  data['departmentName'] = entity.departmentName;
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  data['isExpand'] = entity.isExpand;
  return data;
}

extension GetDepartmentTreeEntityExtension on GetDepartmentTreeEntity {
  GetDepartmentTreeEntity copyWith({
    String? id,
    String? pid,
    String? departmentName,
    List<GetDepartmentTreeEntity>? children,
    bool? isExpand,
  }) {
    return GetDepartmentTreeEntity()
      ..id = id ?? this.id
      ..pid = pid ?? this.pid
      ..departmentName = departmentName ?? this.departmentName
      ..children = children ?? this.children
      ..isExpand = isExpand ?? this.isExpand;
  }
}
